package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhWithdraw;
import com.laowang.project.system.service.MyCyhWithdrawService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 用户申请提现Controller
 *
 * @author laowang
 * @date 2023-06-09
 */
@Api(tags = "用户申请提现接口")
@RestController
@RequestMapping("/withdraw")
public class MyCyhWithdrawController extends BaseController {
    @Autowired
    private MyCyhWithdrawService myCyhWithdrawService;

    @ApiOperation(value = "小程序端 申请提现", notes = "")
    @PostMapping(value = "/user")
    public AjaxResult withdrawUser(@RequestBody MyCyhWithdraw myCyhWithdraw ) {

        myCyhWithdrawService.withdrawUser(myCyhWithdraw);

        return AjaxResult.success("操作成功");
    }


    /**
     * 查询用户申请提现列表
     */
    @ApiOperation(value = "查询用户申请提现列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:withdraw:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyCyhWithdraw myCyhWithdraw) {
        startPage();
        List<MyCyhWithdraw> list = myCyhWithdrawService.selectMyCyhWithdrawList(myCyhWithdraw);
        return getDataTable(list);
    }

    /**
     * 导出用户申请提现列表
     */
    @ApiOperation(value = "导出用户申请提现列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:withdraw:export')")
    @GetMapping("/export")
    public AjaxResult export(MyCyhWithdraw myCyhWithdraw) {
        List<MyCyhWithdraw> list = myCyhWithdrawService.selectMyCyhWithdrawList(myCyhWithdraw);
        ExcelUtil<MyCyhWithdraw> util = new ExcelUtil<MyCyhWithdraw>(MyCyhWithdraw.class);
        return util.exportExcel(list, "withdraw");
    }

    /**
     * 获取用户申请提现详细信息
     */
    @ApiOperation(value = "获取用户申请提现详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:withdraw:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhWithdrawService.selectMyCyhWithdrawById(id));
    }

    /**
     * 新增用户申请提现
     */
    @ApiOperation(value = "新增用户申请提现",notes = "")
    @PreAuthorize("@ss.hasPermi('my:withdraw:add')")
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhWithdraw myCyhWithdraw) {
        return toAjax(myCyhWithdrawService.insertMyCyhWithdraw(myCyhWithdraw));
    }

    /**
     * 修改用户申请提现
     */
    @ApiOperation(value = "修改用户申请提现",notes = "")
    @PreAuthorize("@ss.hasPermi('my:withdraw:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhWithdraw myCyhWithdraw) {
        return toAjax(myCyhWithdrawService.updateMyCyhWithdraw(myCyhWithdraw));
    }

    /**
     * 删除用户申请提现
     */
    @ApiOperation(value = "删除用户申请提现",notes = "")
    @PreAuthorize("@ss.hasPermi('my:withdraw:remove')")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhWithdrawService.deleteMyCyhWithdrawByIds(ids));
    }
}
